/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dp1.pucp.Simulacion.VIsta;

import com.dp1.pucp.Util.Validaciones;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author ubuntu64
 */
public class MantSimulacionGUI2 extends javax.swing.JInternalFrame {

    private JFrame padre;

    public JFrame getPadre() {
        return padre;
    }

    /**
     * Creates new form MantSimulacionGUI2
     */
    public MantSimulacionGUI2() {
        initComponents();
        this.setTitle("Simulación");
        try {
            setFrameIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/hombre_icono.png")));
        } catch (Exception ex) {
        }
    }

    public JTable getTabla() {
        return this.tblProductos;
    }

    public void mostrarError(String msn) {
        Validaciones.mostrarMensajeErrorVal(msn);
    }

    public void mostrarAviso(String msn) {
        Validaciones.mostrarMensajeAvisoVal(msn);
    }

    public void limpiarDatos() {
        ((DefaultTableModel) this.getTabla().getModel()).setRowCount(0);
        ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
        this.getTabla().setValueAt("Galleta Soda", 0, 0);
        this.getTabla().setValueAt(0, 0, 1);
        ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
        this.getTabla().setValueAt("Galleta Decorada", 1, 0);
        this.getTabla().setValueAt(0, 1, 1);
        ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
        this.getTabla().setValueAt("Galleta Rellena", 2, 0);
        this.getTabla().setValueAt(0, 2, 1);
    }

    public int getTurno() {
        return cmbTurno.getSelectedIndex();
    }

    public int getGalletaSoda() {
        int valor = 0;
        for (int i = 0; i < this.getTabla().getRowCount(); i++) {
            if (this.getTabla().getValueAt(i, 0) == "Galleta Soda") {
                valor = (int) this.getTabla().getValueAt(i, 1);
            }
        }
        return valor;
    }

    public int getGalletaRellena() {
        int valor = 0;
        for (int i = 0; i < this.getTabla().getRowCount(); i++) {
            if (this.getTabla().getValueAt(i, 0) == "Galleta Rellena") {
                valor = (int) this.getTabla().getValueAt(i, 1);
            }
        }
        return valor;
    }

    public int getGalletasDecorada() {
        int valor = 0;
        for (int i = 0; i < this.getTabla().getRowCount(); i++) {
            if (this.getTabla().getValueAt(i, 0) == "Galleta Decorada") {
                valor = (int) this.getTabla().getValueAt(i, 1);
            }
        }
        return valor;
    }

    public void setGalletas(int cantSoda, int cantDecorada, int cantRellena) {
        ((DefaultTableModel) this.getTabla().getModel()).setRowCount(0);
        int i = 0;
        if (cantSoda > 0) {
            ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
            this.getTabla().setValueAt("Galleta Soda", i, 0);
            this.getTabla().setValueAt(cantSoda, i, 1);
            i++;
        }
        if (cantDecorada > 0) {
            ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
            this.getTabla().setValueAt("Galleta Decorada", i, 0);
            this.getTabla().setValueAt(cantDecorada, i, 1);
            i++;
        }
        if (cantRellena > 0) {
            ((DefaultTableModel) this.getTabla().getModel()).setRowCount(this.getTabla().getRowCount() + 1);
            this.getTabla().setValueAt("Galleta Rellena", i, 0);
            this.getTabla().setValueAt(cantRellena, i, 1);
        }
    }
//    public void setGalletaSoda(int cant){
//        this.txtCampoGalletaSoda.setText(String.valueOf(cant));
//        
//    }
//    
//    public void setGalletaDecorada(int cant){
//        this.txtCampoGalletaDecorada.setText(String.valueOf(cant));
//        
//    }
//    
//    public void setGalletaRellena(int cant){
//        this.txtCampoGalletaRellena.setText(String.valueOf(cant));
//        
//    }

    public ArrayList<String> listarTurno() {
        ArrayList<String> estados = new ArrayList<>();
        cmbTurno.addItem("MAÑANA");
        cmbTurno.addItem("TARDE");
        cmbTurno.addItem("NOCHE");
        return estados;
    }

    public void setTurno(int turno) {
        cmbTurno.setSelectedIndex(turno);
    }

    public void fijarComboBox() {
        cmbTurno.setEnabled(false);
        System.out.println(" " + (cmbTurno.getSelectedIndex() + 1));
    }

    public void addLimpiarListener(ActionListener ml) {
        this.btnLimpiar.addActionListener(ml);
    }

    public void addEmpleadosListener(ActionListener ml) {
        this.btnAsignacionEmpleados.addActionListener(ml);
    }

    public void addMaquinasListener(ActionListener ml) {
        this.btnAsignacionMaquinas.addActionListener(ml);
    }

    public void addseleccionTurnoListener(ItemListener ml) {
        this.cmbTurno.addItemListener(ml);
    }

    public void addSimularListener(ActionListener ml) {
        this.btnSimular.addActionListener(ml);
    }

    public void addVolverListener(ActionListener ml) {
        this.btnVolver.addActionListener(ml);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        cmbTurno = new javax.swing.JComboBox();
        btnAsignacionEmpleados = new javax.swing.JButton();
        btnAsignacionMaquinas = new javax.swing.JButton();
        btnVolver = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblProductos = new javax.swing.JTable();
        btnSimular = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();

        setClosable(true);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Simulacion de Produccion"));

        jLabel4.setText("Turno");

        btnAsignacionEmpleados.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnAsignacionEmpleados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/manLoguin.png"))); // NOI18N
        btnAsignacionEmpleados.setText("Asignacion Empleados");
        btnAsignacionEmpleados.setBorderPainted(false);
        btnAsignacionEmpleados.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAsignacionEmpleados.setMaximumSize(new java.awt.Dimension(57, 29));
        btnAsignacionEmpleados.setMinimumSize(new java.awt.Dimension(57, 29));
        btnAsignacionEmpleados.setPreferredSize(new java.awt.Dimension(57, 29));
        btnAsignacionEmpleados.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btnAsignacionEmpleados.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        btnAsignacionMaquinas.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnAsignacionMaquinas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/llavesilla.png"))); // NOI18N
        btnAsignacionMaquinas.setText("Asignacion Maquinas");
        btnAsignacionMaquinas.setBorderPainted(false);
        btnAsignacionMaquinas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAsignacionMaquinas.setMaximumSize(new java.awt.Dimension(57, 29));
        btnAsignacionMaquinas.setMinimumSize(new java.awt.Dimension(57, 29));
        btnAsignacionMaquinas.setPreferredSize(new java.awt.Dimension(57, 29));
        btnAsignacionMaquinas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        btnVolver.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnVolver.setText("Volver a Asignacion Pedidos Producto");
        btnVolver.setBorderPainted(false);
        btnVolver.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnVolver.setMaximumSize(new java.awt.Dimension(57, 29));
        btnVolver.setMinimumSize(new java.awt.Dimension(57, 29));
        btnVolver.setPreferredSize(new java.awt.Dimension(57, 29));
        btnVolver.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Productos"));

        tblProductos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Producto", "Cantidad"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblProductos);
        tblProductos.getColumnModel().getColumn(0).setResizable(false);
        tblProductos.getColumnModel().getColumn(1).setResizable(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnAsignacionEmpleados, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnAsignacionMaquinas, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(50, 50, 50)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addGap(18, 18, 18)
                                        .addComponent(cmbTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(137, 137, 137)
                                .addComponent(btnVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 45, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAsignacionEmpleados, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAsignacionMaquinas, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cmbTurno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(btnVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
        );

        btnSimular.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnSimular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/settings.png"))); // NOI18N
        btnSimular.setText("Simular");
        btnSimular.setBorderPainted(false);
        btnSimular.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSimular.setMaximumSize(new java.awt.Dimension(57, 29));
        btnSimular.setMinimumSize(new java.awt.Dimension(57, 29));
        btnSimular.setPreferredSize(new java.awt.Dimension(57, 29));
        btnSimular.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        btnLimpiar.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/clear.png"))); // NOI18N
        btnLimpiar.setText("Limpiar");
        btnLimpiar.setBorderPainted(false);
        btnLimpiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnLimpiar.setMaximumSize(new java.awt.Dimension(57, 29));
        btnLimpiar.setMinimumSize(new java.awt.Dimension(57, 29));
        btnLimpiar.setPreferredSize(new java.awt.Dimension(57, 29));
        btnLimpiar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnSimular, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnSimular, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAsignacionEmpleados;
    private javax.swing.JButton btnAsignacionMaquinas;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JButton btnSimular;
    private javax.swing.JButton btnVolver;
    private javax.swing.JComboBox cmbTurno;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tblProductos;
    // End of variables declaration//GEN-END:variables
}
